<template>
  <div class="wrapper">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside :style="{ width: !isCollapse ? '200px' : '' }">
        <div
          v-show="!isCollapse"
          class="title"
        >
          <el-avatar icon="el-icon-user-solid">&nbsp;</el-avatar
          ><span>烫卤局管理系统</span>
        </div>
        <el-menu
          :unique-opened="true"
          :collapse="isCollapse"
          router
          :default-active="$route.path"
          text-color="#fff"
          background-color="#23345E"
        >
          <Aside :menu="menu"></Aside>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 头部 -->
        <el-header>
          <Header></Header>
        </el-header>
        <div class="navBar">
          <el-row type="flex" align="middle">
              <el-col :span="22">
                <Navbar :key="$route.path"></Navbar>
              </el-col>
            <el-col :span="2"><i class="el-icon-refresh-right refresh" @click="refreshHand"></i></el-col>
          </el-row>
        </div>
        <el-main id="main">
            <router-view v-slot="{ Component }">
              <keep-alive :include="$store.state.includeList">
                  <component :is="Component" />
              </keep-alive>
            </router-view>
        </el-main>
        <el-footer>烫卤局管理服务有限公司（2021）</el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Header from "@/components/Header.vue";
import Navbar from "@/components/Navbar.vue";
import Aside from "@/components/Aside.vue";
import { mapState, mapMutations } from "vuex";
import { getCurrentInstance } from "vue";
import { useStore } from "vuex";
import { ElNotification } from "element-plus";
export default {
    inject: ['reload'],
    name:"Layout",
  components: { Header, Navbar, Aside },
  props: {},
  data() {
    return {
      menuArr: [],
        includeList: []
    };
  },
    computed: {
    ...mapState(["tagArr", "menu", "isCollapse", "includeList"]),
  },
  methods: {
      refreshHand(){
          this.reload()
      }
  },
};
</script>
<style lang="scss" scoped>
.wrapper {
  .el-container {
    height: 100vh;
    background: #f0f2f5;
    .refresh{
      cursor: pointer;
      color:black;
      font-weight: bold;
    }
    // 侧边栏
    /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
    .el-aside ::-webkit-scrollbar {
      width: 0px;
      height: 0px;
      background-color: #f3f4f3;
    }
    /*定义滚动条轨道 内阴影+圆角*/
    .el-aside ::-webkit-scrollbar-track {
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
      border-radius: 10px;
      background-color: #f3f4f3;
    }
    /*定义滑块 内阴影+圆角*/
    .el-aside ::-webkit-scrollbar-thumb {
      border-radius: 10px;
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
      background-color: #cccccc;
    }
    .el-aside {
      background-color: #23345e;
      color: #fff;
      text-align: left;
      transition: width .2s;
      .title {
        display: flex;
        align-items: center;
        height: 60px;
        justify-content: center;
        color: #fff;
        transition: width .2s;
      }
      .el-menu {
        border-right: none;
      }
    }
    // 头部
    .el-header {
      background-color: #fff;
      color: #333;
      text-align: center;
      line-height: 60px;
    }
    // 内容区域
    .el-main {
      margin: 15px;
      padding: 5px;
      box-sizing: border-box;
      border: none;
      overflow-y: auto;
      .el-card {
        height: 100%;
        box-sizing: border-box;
      }
    }

    // 底部区域
    .el-footer {
      height: 30px !important;
      color: #333;
      text-align: center;
      line-height: 30px;
      font-size: 12px;
    }
    .navBar {
      height: 40px;
      margin-top: 4px;
      display: table;
      width: 100%;
      align-items: center;
      background: #fff;
    }
    .logo {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      border: 1px solid gainsboro;
      margin: 0 6px;
    }
  }
}
.fade-enter-active,
.fade-leave-active {
  transition: all 0.3s ease;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
.el-menu--collapse :deep() .el-submenu .el-submenu__title span {
  display: none;
}
.el-menu--collapse :deep() .el-menu-item span {
  display: none;
}
.el-menu--collapse :deep() .el-submenu .el-submenu__title .el-icon-arrow-right {
  display: none;
}
</style>